/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package azhar.com;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Al-Insan
 */
public class PropertiesFile {

    private Properties prop;

    public PropertiesFile() throws Exception{
        prop = new Properties();
        readProp();
    }

    public PropertiesFile(Properties prop) {
        this.prop = prop;
    }

    public Properties getProp() {
        return prop;
    }

    public void setProp(Properties prop) {
        this.prop = prop;
    }

    public void readProp() throws Exception {
        prop.load(new FileInputStream("com/conf.properties"));
    }

    public String getValue(String key){
        return prop.getProperty(key);
    }

    public void writeProp(String key, String word) throws Exception{
        prop.setProperty(key, word);
        prop.save(new FileOutputStream("com/conf.properties"), "File Configuration");
    }
//
//    public static void main(String[] args) {
//        try {
//            PropertiesFile file = new PropertiesFile();
////            file.writeProp("drowssap", "bismillah");
//            file.readProp();
//            System.out.println(file.getValue("drowssap"));
//        } catch (Exception ex) {
//            Logger.getLogger(PropertiesFile.class.getName()).log(Level.SEVERE, null, ex);
//        }
//
//    }

}
